﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using PPIDesktopClient.Entities;
using PPIDesktopClient.General;
using System.Data;
using PPIProxy;
using VMind.Global;
using PPIMobileInterface;

namespace PPIDesktopClient.Logic
{
    public class LXMissionStructures_PoleSpecies
    {
        public static List<EXMissionStructures_PoleSpecies> SelectAllIdName(DataTable dt)
        {
            List<EXMissionStructures_PoleSpecies> _XMissionStructures_PoleSpeciesList = new List<EXMissionStructures_PoleSpecies>();
            EXMissionStructures_PoleSpecies _XMissionStructures_PoleSpecies;

            foreach (DataRow  dr in dt.Rows)
            {
                _XMissionStructures_PoleSpecies = new EXMissionStructures_PoleSpecies(ConvertHelper.ToInt32(dr["XMissionStructures_PoleSpeciesId"]), dr["Name"].ToString());
                _XMissionStructures_PoleSpeciesList.Add(_XMissionStructures_PoleSpecies);
            }
            return _XMissionStructures_PoleSpeciesList;
        }
        public static List<EXMissionStructures_PoleSpecies> SelectAllIdName()
        {
            ConfigReader _Reader = ConfigReader.GetInstance();
            DataTable dt = WXMissionStructures_PoleSpecies.SelectAllIdName(_Reader.GetConnectionString()).Tables[0];
            return SelectAllIdName(dt);
        }
        public static void InsertSpecies(string connectionString)
        {

            StringBuilder _query = new StringBuilder();
            List<EXMissionStructures_PoleSpecies> _species = LXMissionStructures_PoleSpecies.SelectAllIdName();
            foreach (EXMissionStructures_PoleSpecies e in _species)
            {
                _query.AppendLine("insert into tb_Lookups (LookupValue,LookupText,LookupTypeFk) values (" + e.XMissionStructures_PoleSpeciesId + ",'" + e.Name + "','Species')");
            }
            Utils.InsertSpecies(connectionString, _query.ToString());
        }
    }
}
